﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace idea.tools
{
    class Progress:IProgress
    {
       
        private long itemsCount;
        public delegate void DOSTH(long i);
        public delegate void OVER();
        private  Label msg1;
        private  Label msg2;

        public Progress(Label msg1, Label msg2)
        {
            this.msg1=msg1;
            this.msg2=msg2;
           
         
        }
        
        public void Init(long count){
            
            this.itemsCount = count;

            if (this.msg1.InvokeRequired)
            {
                DOSTH d = Init;

                msg1.Invoke(d, new object[] { itemsCount });
            }
            else
            {
                this.msg1.Text = String.Format("共有{0}项需要结算。",count);
            }
        }
        public void Step(long i)
        {
            String text = i.ToString();

            if (this.msg2.InvokeRequired)
            {
                DOSTH d = Step;
                msg1.Invoke(d, new object[] { i });
            }
            else
            {
                this.msg2.Text = text;
            }

        }
        public void Over()
        {
            if (this.msg2.InvokeRequired)
            {
                OVER d = Over;
                msg1.Invoke(d, new object[] { });
            }
            else
            {
                this.msg2.Text = "结算成功！";
            }
        }
  
    }
}
